Fix #2173: Honor AbortOnConnectFail on sentinel path#3063
Open
IvanWennberg wants to merge 2 commits intoStackExchange:mainfrom
Open
Fix #2173: Honor AbortOnConnectFail on sentinel path#3063IvanWennberg wants to merge 2 commits intoStackExchange:mainfrom
IvanWennberg wants to merge 2 commits intoStackExchange:mainfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When
Connectis called withServiceNameandAbortOnConnectFail=false,the non-sentinel path returns a disconnected multiplexer that reconnects in
the background. The sentinel path ignores this flag and throws unconditionally
with "Sentinel: The ConnectionMultiplexer is not a Sentinel connection.
Detected as: Standalone".
This is because
SentinelConnectreturns a disconnected multiplexer(ServerType defaults to Standalone when the handshake hasn't completed),
and
GetSentinelMasterConnectionthrows when it sees the wrong ServerType— without checking AbortOnConnectFail.
Changes in
GetSentinelMasterConnection:connection hasn't completed handshake.
return a disconnected multiplexer with OnManagedConnectionFailed /
OnManagedConnectionRestored wired up instead of throwing. Self-healing
works via the existing SwitchPrimary retry timer.
While Sentinel isn't the future direction for Redis HA, it's still widely
used — especially with Valkey, AWS ElastiCache, and Kubernetes deployments
that haven't moved to cluster mode.
Tests in
SentinelAbortOnConnectTests.cs— no running Redis/Sentinelinstance required. Self-healing reuses the existing SwitchPrimary mechanism
tested by
ManagedPrimaryConnectionEndToEndWithFailoverTest.